package cn.edu.lzu.dao;

import cn.edu.lzu.entity.Permission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @PackageName: cn.edu.lzu.dao
 * @InterfaceName: PermissionMapper
 * @Description: TODO
 * @Author: 张琦[QQ:3098086691]
 * @Date: 2020/5/5 17:56
 * @Version: 1.0
 */
@Mapper
public interface PermissionMapper {
    @Select("select * from permission")
    List<Permission> selPermissions();

    @Select("select * from permission where permission_id in (select permission_id from role_permission where role_id=#{roleId} and is_deleted=0)")
    List<Permission> selPermissionsByRoleId(int roleId, long unitId);

    @Select("select * from permission where permission_id in (select permission_id from role_permission where is_deleted=0 and role_id in (select role_id from examiner_role where is_deleted=0 and examiner_id=#{examinerId}))")
    List<Permission> selExaminerPermissions(long examinerId);
}
